home *** CD-ROM | disk | FTP | other *** search
- /**
- --
- -- App: Getting Started w/QD GX (WWDC)
- --
- --
- -- Version: 1.0 4/93: added all of the calls required to support the "Getting
- -- Started with QuickDraw™ GX" session at the WWDC '93
- --
- -- 8/93: updated file to work with the ß2 "GXified" interface files
- --
- --
- -- File: Getting Started GX - misc.c
- --
- --
- -- Comments: This file contains utility and menu handling routines.
- --
- --
- -- Components: Getting Started GX - main.c
- -- Getting Started GX - main.h
- -- Getting Started GX - shapes.c
- -- Getting Started GX - printing.c
- -- Getting Started GX - misc.c
- -- Getting Started QD GX.π.rsrc
- --
- -- The file titled: "Getting Started GX - main.c" contains the code required to
- -- intialize and tear down the QuickDraw GX world, and the event loop.
- --
- -- The file titled: "Getting Started GX - shapes.c" contains of the code used to
- -- create and manipulate the shapes draw into the window.
- --
- -- The file titled: "Getting Started GX - printing.c" contains of the code used to
- -- print the contents of the window.
- --
- --
- -- QuickDraw GX
- -- Libraries
- -- Used: This application uses the following QuickDraw GX library code files:
- -- "color library.c", "font library.c", "graphics debug library.c",
- -- "layout library.c", "qd library.c", "shape library.c",
- -- "transferMode library.c", and "transform library.c".
- --
- --
- -- Notes: 1) Print this file in landscape for the best results
- -- 2) If you are using THINK C v5.x, I have added THINK markers to navigate the code.
- -- 3) This code was adapted from the "Banana Jr." QuickDraw GX sample.
- --
- --
- -- Author: Pete "Luke" Alexander
- -- Developer Technical Support
- -- AppleLink: DEVSUPPORT
- --
- --
- -- ©1992 - 1993 Apple Computer, Inc.
- -- All rights reserved.
- --
- **/
-
- #include <Desk.h>
- #include <Menus.h>
-
-
- #include "graphics toolbox.h"
- #include "graphics libraries.h"
- #include "PrintingManager.h"
- #include "Getting Started GX - main.h"
-
-
- /*------ DoMenuCommand ---------------------------------------------------------------------------------------*/
- //
- // This routine handles the dispatching of our menu requests.
- //
- void DoMenuCommand(long menuResult)
- {
- short menuID;
- short menuItem;
- Str255 daName;
- OSErr err;
- gxDialogResult result;
-
- menuID = menuResult >>16;
- menuItem = menuResult & 0x0000ffff;
-
- switch (menuID)
- {
- case mApple:
- switch (menuItem)
- {
- case iAbout: /* display About box */
- break;
-
- default: /* handle DA selection */
- GetItem(GetMHandle(mApple), menuItem, daName);
- OpenDeskAcc(daName);
- break;
- }
- break;
-
- case mFile:
- switch (menuItem)
- {
- case iNew:
- /* create new window */
-
- err = DoCreateNew();
- break;
-
- case iOpen:
- /* open saved window */
-
- break;
-
- case iClose:
- /* close front window */
-
- DoDispose(FrontWindow());
- break;
-
- case iSave:
- /* save front window */
-
- break;
-
- case iPrintOne:
- /* perform print-one */
-
- err = DoPrintOneCopy(FrontWindow());
- break;
-
- case iDocumentSetup:
- /* perform document setup */
-
- HiliteMenu(0);
- err = DoFormat(FrontWindow(), &result);
- break;
-
- case iByPageSetup:
- /* perform by page setup */
- HiliteMenu(0);
- break;
-
-
- case iPrint:
- /* perform print */
-
- HiliteMenu(0);
- err = DoPrinting(FrontWindow());
- break;
-
- case iQuit:
- gQuitting = true;
- break;
- }
- break;
-
- case mEdit:
- break;
-
- case mGraphics:
- switch (menuItem)
- {
- case iCreateABlackRectangle:
- CreateABlackRectangle (FrontWindow());
- break;
-
- case iColorTheRectangle:
- ColorTheRectangle (FrontWindow());
- break;
-
- case iCreateAQ:
- CreateAQ(FrontWindow());
- break;
-
- case iOutlineTheQ:
- OutlineTheQ(FrontWindow());
- break;
-
- case iCreateAD:
- CreateAD(FrontWindow());
- break;
-
- case iCreateAG:
- CreateAG(FrontWindow());
- break;
-
- case iCreateAX:
- CreateAX(FrontWindow());
- break;
- }
- break;
-
- case mTypography:
- switch (menuItem)
- {
- case iCreateLayout:
- CreateNewLayoutShape (FrontWindow());
- break;
-
- case iAddKanjiToLayout:
- AddKanjiToLayout (FrontWindow());
- break;
-
- case iPerspectLayout:
- PerspectLayout(FrontWindow());
- break;
- }
- break;
-
- }
- HiliteMenu(0);
- }
-
-
-
- /*------ GetDocShape ---------------------------------------------------------------------------------*/
- //
- // This utility routine returns the page shape (contents) attached to a window's document.
- //
- gxShape GetDocShape(WindowPtr wind)
- {
- TH_Doc doc;
- gxShape docPage = nil;
-
- if (wind)
- {
- doc = (TH_Doc) GetWRefCon(wind);
- docPage = (*doc)->docPage;
- }
-
- return docPage;
- }
-
-
- /*------ GetDocJob -----------------------------------------------------------------------------------*/
- //
- // This utility routine returns the print job attached to a window's document.
- //
- gxJob GetDocJob(WindowPtr wind)
- {
- TH_Doc doc;
- gxJob docJob = nil;
-
- if (wind)
- {
- doc = (TH_Doc) GetWRefCon(wind);
- docJob = (*doc)->docJob;
- }
-
- return docJob;
- }
-